import React from 'react';
import { observer, inject } from 'mobx-react';
import WeaTextarea from '../../public/wf-form-textarea/index';

@inject('layoutStore')
@observer
export default class TextareaElement extends React.Component{
    doChangeEvent = (value) => {
        const { layoutStore,fieldMark } = this.props;
		layoutStore.changeSingleFieldValue(fieldMark, {value: value});
	}
    render() {
        const { fieldMark,fieldAttr,symbol,rowIndex,cellObj,fieldObj } = this.props;
        let { baseProps } = this.props;
        const { variable } = fieldObj;
        if(baseProps.viewAttr !== 1){   //可编辑空值显示的默认值
            baseProps.emptyShowContent = variable.get("emptyShowContent") || "";
        }
        const textheight = "textheight" in fieldAttr ? fieldAttr.textheight : 4;
        const length = "length" in fieldAttr ? fieldAttr.length : 4000;
        const fielddbtype = fieldAttr.fielddbtype;
        return(
            <WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@c5kpha`} 
                textheight = {textheight}
                length = {length}
                fielddbtype = {fielddbtype}
                onChange = {this.doChangeEvent}
                {...baseProps}
            />
        )
    }
}